home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / a-strmap.ads < prev    next >
Text File  |  1996-01-30  |  24KB  |  402 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --                     A D A . S T R I N G S . M A P S                      --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.15 $                             --
  10. --                                                                          --
  11. -- This specification is adapted from the Ada Reference Manual for use with --
  12. -- GNAT.  In accordance with the copyright of that document, you can freely --
  13. -- copy and modify this specification,  provided that if you redistribute a --
  14. -- modified version,  any changes that you have made are clearly indicated. --
  15. --                                                                          --
  16. ------------------------------------------------------------------------------
  17.  
  18. with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
  19.  
  20. package Ada.Strings.Maps is
  21. pragma Preelaborate (Maps);
  22.  
  23.    --------------------------------
  24.    -- Character Set Declarations --
  25.    --------------------------------
  26.  
  27.    type Character_Set is private;
  28.    --  Representation for a set of character values:
  29.  
  30.    Null_Set : constant Character_Set;
  31.  
  32.    ---------------------------
  33.    -- Constructors for Sets --
  34.    ---------------------------
  35.  
  36.    type Character_Range is record
  37.       Low  : Character;
  38.       High : Character;
  39.    end record;
  40.    --  Represents Character range Low .. High
  41.  
  42.    type Character_Ranges is array (Positive range <>) of Character_Range;
  43.  
  44.    function To_Set    (Ranges : in Character_Ranges) return Character_Set;
  45.  
  46.    function To_Set    (Span   : in Character_Range)  return Character_Set;
  47.  
  48.    function To_Ranges (Set    : in Character_Set)    return Character_Ranges;
  49.  
  50.    ----------------------------------
  51.    -- Operations on Character Sets --
  52.    ----------------------------------
  53.  
  54.    function "="   (Left, Right : in Character_Set) return Boolean;
  55.  
  56.    function "not" (Right       : in Character_Set) return Character_Set;
  57.    function "and" (Left, Right : in Character_Set) return Character_Set;
  58.    function "or"  (Left, Right : in Character_Set) return Character_Set;
  59.    function "xor" (Left, Right : in Character_Set) return Character_Set;
  60.    function "-"   (Left, Right : in Character_Set) return Character_Set;
  61.  
  62.    pragma Import (Intrinsic, "=");
  63.    pragma Import (Intrinsic, "not");
  64.    pragma Import (Intrinsic, "and");
  65.    pragma Import (Intrinsic, "or");
  66.    pragma Import (Intrinsic, "xor");
  67.    --  These are not intrinsic in the RM, so this is not quite right ???
  68.  
  69.    function Is_In
  70.      (Element : in Character;
  71.       Set     : in Character_Set)
  72.       return    Boolean;
  73.  
  74.    function Is_Subset
  75.      (Elements : in Character_Set;
  76.       Set      : in Character_Set)
  77.       return     Boolean;
  78.  
  79.    function "<="
  80.      (Left  : in Character_Set;
  81.       Right : in Character_Set)
  82.       return  Boolean
  83.    renames Is_Subset;
  84.  
  85.    subtype Character_Sequence is String;
  86.    --  Alternative representation for a set of character values
  87.  
  88.    function To_Set (Sequence  : in Character_Sequence) return Character_Set;
  89.  
  90.    function To_Set (Singleton : in Character)          return Character_Set;
  91.  
  92.    function To_Sequence (Set : in Character_Set) return Character_Sequence;
  93.  
  94.    ------------------------------------
  95.    -- Character Mapping Declarations --
  96.    ------------------------------------
  97.  
  98.    type Character_Mapping is private;
  99.    --  Representation for a character to character mapping:
  100.  
  101.    function Value
  102.      (Map     : in Character_Mapping;
  103.       Element : in Character)
  104.       return    Character;
  105.  
  106.    Identity : constant Character_Mapping;
  107.  
  108.    ----------------------------
  109.    -- Operations on Mappings --
  110.    ----------------------------
  111.  
  112.    function To_Mapping
  113.      (From, To : in Character_Sequence)
  114.       return     Character_Mapping;
  115.  
  116.    function To_Domain
  117.      (Map  : in Character_Mapping)
  118.       return Character_Sequence;
  119.  
  120.    function To_Range
  121.      (Map  : in Character_Mapping)
  122.       return Character_Sequence;
  123.  
  124.    type Character_Mapping_Function is
  125.       access function (From : in Character) return Character;
  126.  
  127.    ------------------
  128.    -- Private Part --
  129.    ------------------
  130.  
  131. private
  132.    pragma Inline (Is_In);
  133.    pragma Inline (Value);
  134.  
  135.    type Character_Set is array (Character) of Boolean;
  136.    pragma Pack (Character_Set);
  137.  
  138.    Null_Set : constant Character_Set := (others => False);
  139.  
  140.    type Character_Mapping is array (Character) of Character;
  141.    pragma Pack (Character_Mapping);
  142.  
  143.    Identity : constant Character_Mapping :=
  144.      (NUL                         &  -- NUL                             0
  145.       SOH                         &  -- SOH                             1
  146.       STX                         &  -- STX                             2
  147.       ETX                         &  -- ETX                             3
  148.       EOT                         &  -- EOT                             4
  149.       ENQ                         &  -- ENQ                             5
  150.       ACK                         &  -- ACK                             6
  151.       BEL                         &  -- BEL                             7
  152.       BS                          &  -- BS                              8
  153.       HT                          &  -- HT                              9
  154.       LF                          &  -- LF                             10
  155.       VT                          &  -- VT                             11
  156.       FF                          &  -- FF                             12
  157.       CR                          &  -- CR                             13
  158.       SO                          &  -- SO                             14
  159.       SI                          &  -- SI                             15
  160.       DLE                         &  -- DLE                            16
  161.       DC1                         &  -- DC1                            17
  162.       DC2                         &  -- DC2                            18
  163.       DC3                         &  -- DC3                            19
  164.       DC4                         &  -- DC4                            20
  165.       NAK                         &  -- NAK                            21
  166.       SYN                         &  -- SYN                            22
  167.       ETB                         &  -- ETB                            23
  168.       CAN                         &  -- CAN                            24
  169.       EM                          &  -- EM                             25
  170.       SUB                         &  -- SUB                            26
  171.       ESC                         &  -- ESC                            27
  172.       FS                          &  -- FS                             28
  173.       GS                          &  -- GS                             29
  174.       RS                          &  -- RS                             30
  175.       US                          &  -- US                             31
  176.       ' '                         &  -- ' '                            32
  177.       '!'                         &  -- '!'                            33
  178.       '"'                         &  -- '"'                            34
  179.       '#'                         &  -- '#'                            35
  180.       '$'                         &  -- '$'                            36
  181.       '%'                         &  -- '%'                            37
  182.       '&'                         &  -- '&'                            38
  183.       '''                         &  -- '''                            39
  184.       '('                         &  -- '('                            40
  185.       ')'                         &  -- ')'                            41
  186.       '*'                         &  -- '*'                            42
  187.       '+'                         &  -- '+'                            43
  188.       ','                         &  -- ','                            44
  189.       '-'                         &  -- '-'                            45
  190.       '.'                         &  -- '.'                            46
  191.       '/'                         &  -- '/'                            47
  192.       '0'                         &  -- '0'                            48
  193.       '1'                         &  -- '1'                            49
  194.       '2'                         &  -- '2'                            50
  195.       '3'                         &  -- '3'                            51
  196.       '4'                         &  -- '4'                            52
  197.       '5'                         &  -- '5'                            53
  198.       '6'                         &  -- '6'                            54
  199.       '7'                         &  -- '7'                            55
  200.       '8'                         &  -- '8'                            56
  201.       '9'                         &  -- '9'                            57
  202.       ':'                         &  -- ':'                            58
  203.       ';'                         &  -- ';'                            59
  204.       '<'                         &  -- '<'                            60
  205.       '='                         &  -- '='                            61
  206.       '>'                         &  -- '>'                            62
  207.       '?'                         &  -- '?'                            63
  208.       '@'                         &  -- '@'                            64
  209.       'A'                         &  -- 'A'                            65
  210.       'B'                         &  -- 'B'                            66
  211.       'C'                         &  -- 'C'                            67
  212.       'D'                         &  -- 'D'                            68
  213.       'E'                         &  -- 'E'                            69
  214.       'F'                         &  -- 'F'                            70
  215.       'G'                         &  -- 'G'                            71
  216.       'H'                         &  -- 'H'                            72
  217.       'I'                         &  -- 'I'                            73
  218.       'J'                         &  -- 'J'                            74
  219.       'K'                         &  -- 'K'                            75
  220.       'L'                         &  -- 'L'                            76
  221.       'M'                         &  -- 'M'                            77
  222.       'N'                         &  -- 'N'                            78
  223.       'O'                         &  -- 'O'                            79
  224.       'P'                         &  -- 'P'                            80
  225.       'Q'                         &  -- 'Q'                            81
  226.       'R'                         &  -- 'R'                            82
  227.       'S'                         &  -- 'S'                            83
  228.       'T'                         &  -- 'T'                            84
  229.       'U'                         &  -- 'U'                            85
  230.       'V'                         &  -- 'V'                            86
  231.       'W'                         &  -- 'W'                            87
  232.       'X'                         &  -- 'X'                            88
  233.       'Y'                         &  -- 'Y'                            89
  234.       'Z'                         &  -- 'Z'                            90
  235.       '['                         &  -- '['                            91
  236.       '\'                         &  -- '\'                            92
  237.       ']'                         &  -- ']'                            93
  238.       '^'                         &  -- '^'                            94
  239.       '_'                         &  -- '_'                            95
  240.       '`'                         &  -- '`'                            96
  241.       'a'                         &  -- 'a'                            97
  242.       'b'                         &  -- 'b'                            98
  243.       'c'                         &  -- 'c'                            99
  244.       'd'                         &  -- 'd'                           100
  245.       'e'                         &  -- 'e'                           101
  246.       'f'                         &  -- 'f'                           102
  247.       'g'                         &  -- 'g'                           103
  248.       'h'                         &  -- 'h'                           104
  249.       'i'                         &  -- 'i'                           105
  250.       'j'                         &  -- 'j'                           106
  251.       'k'                         &  -- 'k'                           107
  252.       'l'                         &  -- 'l'                           108
  253.       'm'                         &  -- 'm'                           109
  254.       'n'                         &  -- 'n'                           110
  255.       'o'                         &  -- 'o'                           111
  256.       'p'                         &  -- 'p'                           112
  257.       'q'                         &  -- 'q'                           113
  258.       'r'                         &  -- 'r'                           114
  259.       's'                         &  -- 's'                           115
  260.       't'                         &  -- 't'                           116
  261.       'u'                         &  -- 'u'                           117
  262.       'v'                         &  -- 'v'                           118
  263.       'w'                         &  -- 'w'                           119
  264.       'x'                         &  -- 'x'                           120
  265.       'y'                         &  -- 'y'                           121
  266.       'z'                         &  -- 'z'                           122
  267.       '{'                         &  -- '{'                           123
  268.       '|'                         &  -- '|'                           124
  269.       '}'                         &  -- '}'                           125
  270.       '~'                         &  -- '~'                           126
  271.       DEL                         &  -- DEL                           127
  272.       Reserved_128                &  -- Reserved_128                  128
  273.       Reserved_129                &  -- Reserved_129                  129
  274.       BPH                         &  -- BPH                           130
  275.       NBH                         &  -- NBH                           131
  276.       Reserved_132                &  -- Reserved_132                  132
  277.       NEL                         &  -- NEL                           133
  278.       SSA                         &  -- SSA                           134
  279.       ESA                         &  -- ESA                           135
  280.       HTS                         &  -- HTS                           136
  281.       HTJ                         &  -- HTJ                           137
  282.       VTS                         &  -- VTS                           138
  283.       PLD                         &  -- PLD                           139
  284.       PLU                         &  -- PLU                           140
  285.       RI                          &  -- RI                            141
  286.       SS2                         &  -- SS2                           142
  287.       SS3                         &  -- SS3                           143
  288.       DCS                         &  -- DCS                           144
  289.       PU1                         &  -- PU1                           145
  290.       PU2                         &  -- PU2                           146
  291.       STS                         &  -- STS                           147
  292.       CCH                         &  -- CCH                           148
  293.       MW                          &  -- MW                            149
  294.       SPA                         &  -- SPA                           150
  295.       EPA                         &  -- EPA                           151
  296.       SOS                         &  -- SOS                           152
  297.       Reserved_153                &  -- Reserved_153                  153
  298.       SCI                         &  -- SCI                           154
  299.       CSI                         &  -- CSI                           155
  300.       ST                          &  -- ST                            156
  301.       OSC                         &  -- OSC                           157
  302.       PM                          &  -- PM                            158
  303.       APC                         &  -- APC                           159
  304.       No_Break_Space              &  -- No_Break_Space                160
  305.       Inverted_Exclamation        &  -- Inverted_Exclamation          161
  306.       Cent_Sign                   &  -- Cent_Sign                     162
  307.       Pound_Sign                  &  -- Pound_Sign                    163
  308.       Currency_Sign               &  -- Currency_Sign                 164
  309.       Yen_Sign                    &  -- Yen_Sign                      165
  310.       Broken_Bar                  &  -- Broken_Bar                    166
  311.       Section_Sign                &  -- Section_Sign                  167
  312.       Diaeresis                   &  -- Diaeresis                     168
  313.       Copyright_Sign              &  -- Copyright_Sign                169
  314.       Feminine_Ordinal_Indicator  &  -- Feminine_Ordinal_Indicator    170
  315.       Left_Angle_Quotation        &  -- Left_Angle_Quotation          171
  316.       Not_Sign                    &  -- Not_Sign                      172
  317.       Soft_Hyphen                 &  -- Soft_Hyphen                   173
  318.       Registered_Trade_Mark_Sign  &  -- Registered_Trade_Mark_Sign    174
  319.       Macron                      &  -- Macron                        175
  320.       Degree_Sign                 &  -- Degree_Sign                   176
  321.       Plus_Minus_Sign             &  -- Plus_Minus_Sign               177
  322.       Superscript_Two             &  -- Superscript_Two               178
  323.       Superscript_Three           &  -- Superscript_Three             179
  324.       Acute                       &  -- Acute                         180
  325.       Micro_Sign                  &  -- Micro_Sign                    181
  326.       Pilcrow_Sign                &  -- Pilcrow_Sign                  182
  327.       Middle_Dot                  &  -- Middle_Dot                    183
  328.       Cedilla                     &  -- Cedilla                       184
  329.       Superscript_One             &  -- Superscript_One               185
  330.       Masculine_Ordinal_Indicator &  -- Masculine_Ordinal_Indicator   186
  331.       Right_Angle_Quotation       &  -- Right_Angle_Quotation         187
  332.       Fraction_One_Quarter        &  -- Fraction_One_Quarter          188
  333.       Fraction_One_Half           &  -- Fraction_One_Half             189
  334.       Fraction_Three_Quarters     &  -- Fraction_Three_Quarters       190
  335.       Inverted_Question           &  -- Inverted_Question             191
  336.       UC_A_Grave                  &  -- UC_A_Grave                    192
  337.       UC_A_Acute                  &  -- UC_A_Acute                    193
  338.       UC_A_Circumflex             &  -- UC_A_Circumflex               194
  339.       UC_A_Tilde                  &  -- UC_A_Tilde                    195
  340.       UC_A_Diaeresis              &  -- UC_A_Diaeresis                196
  341.       UC_A_Ring                   &  -- UC_A_Ring                     197
  342.       UC_AE_Diphthong             &  -- UC_AE_Diphthong               198
  343.       UC_C_Cedilla                &  -- UC_C_Cedilla                  199
  344.       UC_E_Grave                  &  -- UC_E_Grave                    200
  345.       UC_E_Acute                  &  -- UC_E_Acute                    201
  346.       UC_E_Circumflex             &  -- UC_E_Circumflex               202
  347.       UC_E_Diaeresis              &  -- UC_E_Diaeresis                203
  348.       UC_I_Grave                  &  -- UC_I_Grave                    204
  349.       UC_I_Acute                  &  -- UC_I_Acute                    205
  350.       UC_I_Circumflex             &  -- UC_I_Circumflex               206
  351.       UC_I_Diaeresis              &  -- UC_I_Diaeresis                207
  352.       UC_Icelandic_Eth            &  -- UC_Icelandic_Eth              208
  353.       UC_N_Tilde                  &  -- UC_N_Tilde                    209
  354.       UC_O_Grave                  &  -- UC_O_Grave                    210
  355.       UC_O_Acute                  &  -- UC_O_Acute                    211
  356.       UC_O_Circumflex             &  -- UC_O_Circumflex               212
  357.       UC_O_Tilde                  &  -- UC_O_Tilde                    213
  358.       UC_O_Diaeresis              &  -- UC_O_Diaeresis                214
  359.       Multiplication_Sign         &  -- Multiplication_Sign           215
  360.       UC_O_Oblique_Stroke         &  -- UC_O_Oblique_Stroke           216
  361.       UC_U_Grave                  &  -- UC_U_Grave                    217
  362.       UC_U_Acute                  &  -- UC_U_Acute                    218
  363.       UC_U_Circumflex             &  -- UC_U_Circumflex               219
  364.       UC_U_Diaeresis              &  -- UC_U_Diaeresis                220
  365.       UC_Y_Acute                  &  -- UC_Y_Acute                    221
  366.       UC_Icelandic_Thorn          &  -- UC_Icelandic_Thorn            222
  367.       LC_German_Sharp_S           &  -- LC_German_Sharp_S             223
  368.       LC_A_Grave                  &  -- LC_A_Grave                    224
  369.       LC_A_Acute                  &  -- LC_A_Acute                    225
  370.       LC_A_Circumflex             &  -- LC_A_Circumflex               226
  371.       LC_A_Tilde                  &  -- LC_A_Tilde                    227
  372.       LC_A_Diaeresis              &  -- LC_A_Diaeresis                228
  373.       LC_A_Ring                   &  -- LC_A_Ring                     229
  374.       LC_AE_Diphthong             &  -- LC_AE_Diphthong               230
  375.       LC_C_Cedilla                &  -- LC_C_Cedilla                  231
  376.       LC_E_Grave                  &  -- LC_E_Grave                    232
  377.       LC_E_Acute                  &  -- LC_E_Acute                    233
  378.       LC_E_Circumflex             &  -- LC_E_Circumflex               234
  379.       LC_E_Diaeresis              &  -- LC_E_Diaeresis                235
  380.       LC_I_Grave                  &  -- LC_I_Grave                    236
  381.       LC_I_Acute                  &  -- LC_I_Acute                    237
  382.       LC_I_Circumflex             &  -- LC_I_Circumflex               238
  383.       LC_I_Diaeresis              &  -- LC_I_Diaeresis                239
  384.       LC_Icelandic_Eth            &  -- LC_Icelandic_Eth              240
  385.       LC_N_Tilde                  &  -- LC_N_Tilde                    241
  386.       LC_O_Grave                  &  -- LC_O_Grave                    242
  387.       LC_O_Acute                  &  -- LC_O_Acute                    243
  388.       LC_O_Circumflex             &  -- LC_O_Circumflex               244
  389.       LC_O_Tilde                  &  -- LC_O_Tilde                    245
  390.       LC_O_Diaeresis              &  -- LC_O_Diaeresis                246
  391.       Division_Sign               &  -- Division_Sign                 247
  392.       LC_O_Oblique_Stroke         &  -- LC_O_Oblique_Stroke           248
  393.       LC_U_Grave                  &  -- LC_U_Grave                    249
  394.       LC_U_Acute                  &  -- LC_U_Acute                    250
  395.       LC_U_Circumflex             &  -- LC_U_Circumflex               251
  396.       LC_U_Diaeresis              &  -- LC_U_Diaeresis                252
  397.       LC_Y_Acute                  &  -- LC_Y_Acute                    253
  398.       LC_Icelandic_Thorn          &  -- LC_Icelandic_Thorn            254
  399.       LC_Y_Diaeresis);               -- LC_Y_Diaeresis                255
  400.  
  401. end Ada.Strings.Maps;
  402.